<?php

class ActivityArtProfile extends Zend_Db_Table{

    protected $_name = 'activity_art_profile';  //表名
    protected $_primary='id';		//主键名

    public function getActivityInfo($id){
        $select = $this->select();
        $select->where('id in (?)',$id);
        $result = $this->fetchAll($select)->toArray();
        if($result) return $result[0];
        else return null;
    }

    public function getActivityList($type, $sale_state){
        $select = $this->select();
        if($sale_state == 'myarticles')
        {
            $select->where('art_publisher in (?)',$_SESSION['user']['username']);
            $result = $this->fetchAll($select)->toArray();
            if($result) return $result;
            else return null;
        }
        $select->where('art_type in (?)',$type);
        if($sale_state == 'wait')
            $select->where('art_sale_state in (?)',0);
        else if($sale_state == 'sale')
            $select->where('art_sale_state in (?)',1);
        else if($sale_state == 'end')
            $select->where('art_sale_state in (?)',-1);
        $result = $this->fetchAll($select)->toArray();
        if($result) return $result;
        else return null;
    }

    public function publishArtActivity($new_modify, $article_id, $classid, $title, $place, $time_1,$artist, $report_reporter, $report_compere, $report_reporter_descrip,
                                       $price, $ticket_time, $ticket_status, $ticket_place, $sponsor, $duration,$link, $label, $detail,  $publisher )
    {
        if($classid=="1" || $classid=="2")
        {
            $data = array(
                'art_type' =>$classid ,
                'art_title'  => $title,
                'art_place' => $place,
                'art_sponsor'=> $sponsor,
                    'art_actor'=>$artist ,
                    'art_duration'=>$duration ,
                    'art_play_starttime'=>$time_1 ,
                    'art_price'=>$price ,
                    'art_sale_starttime'=> $ticket_time,
                    'art_sale_state'=> '1',
                    'art_source'=> $link,
                    'art_description'=> $detail,
                    'art_labels'=>$label,
                'art_publisher'=>$publisher
                );
           /* $data = array(
                'art_title'=>'title',
                'art_place'=>'place',
                'art_play_starttime'=>'2011-11-11 12:11:11',
                'art_publisher'=>'liuyq'
            );*/
            if($new_modify=='new')
            {
                if($article_id == '-1')
                    $this->insert($data);
            }
           // $this->insert($data);
        }
    }

}
